package com.yonyou.pmclouds.safetyrectification.assignrecord.service.rmiimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.bp.processor.AuditInfoInsertProcessor;
import com.yonyou.pmclouds.basecom.bp.template.SingleInsertBpTemplate;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.safetyrectification.assignrecord.entity.AssignRecordVO;
import com.yonyou.pmclouds.safetyrectification.assignrecord.mapper.AssignRecordMapper;
import com.yonyou.pmclouds.safetyrectification.assignrecord.service.IAssignRecordMaintain;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author tanghuan
 * @date 2019/10/26
 */
@Service(interfaceClass = IAssignRecordMaintain.class, version = ApplicationConsts.APPLICATION_VERSION)
public class AssignRecordMaintainImpl implements IAssignRecordMaintain {
    @Autowired
    private AssignRecordMapper mapper;

    @Override
    public AssignRecordVO add(AssignRecordVO vo) throws BusinessException {
        if (vo == null)
            return new AssignRecordVO();

        SingleInsertBpTemplate<AssignRecordVO> bp = new SingleInsertBpTemplate<>(mapper);
        bp.addBeforeProcessor(new AuditInfoInsertProcessor<AssignRecordVO>());

        return bp.insert(vo);
    }
}
